#!/bin/sh

if [ $UID != 0 ]
then
	echo "please run as root privilege."
	exit
fi

rmmod mem.ko 2>/dev/null
insmod mem.ko
if [ $? -ne 0 ]
then
	echo "insmod failed"
	exit
fi

result=$(dmesg|tac|awk '/free->/{print $0;exit}')
free=$(echo $result|awk -F '|' '{print $1}' | awk '{print $2}')
inactive=$(echo $result|awk -F '|' '{print $2}' | awk -F ':' '{print $2}')
active=$(echo $result|awk -F '|' '{print $3}' | awk -F ':' '{print $2}')
total_avail=$((inactive+active+free))

echo "free:"$free,"relclaim-able(inactive):"$inactive,"reclaim-able(active):"$active," |Total avail: "$total_avail

rmmod mem.ko
if [ $? -ne 0 ]
then
	echo "rmmod failed"
	exit
fi

